Skip to content

Add support for character device GPIO #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 2, 2020

Conversation

almusil
Copy link
Contributor

@almusil almusil commented Dec 20, 2019

No description provided.

@almusil almusil requested a review from a team as a code owner December 20, 2019 10:58
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nastevens (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added S-waiting-on-review Status: Review is incomplete T-embedded-linux labels Dec 20, 2019
@almusil almusil mentioned this pull request Dec 20, 2019
@almusil
Copy link
Contributor Author

almusil commented Dec 20, 2019

Alternative to #29

ryankurte
ryankurte previously approved these changes Jan 4, 2020
Copy link
Contributor

@ryankurte ryankurte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@rust-embedded/embedded-linux folks do you have any opinions on this approach?

bors try

bors bot added a commit that referenced this pull request Jan 4, 2020
@bors
Copy link
Contributor

bors bot commented Jan 4, 2020

try

Build failed

@posborne
Copy link
Member

posborne commented Jan 4, 2020

The changes generally look Ok, I had some extra concerns at first related to semver but 0.3 is not published yet so that should be OK.

Probably the main thing to consider changing here would be to do the additional conditional compilation to allow for completely dropping the sysfs gpio dep if the feature is not selected.

I question the choice to expose struct Pin with the same name for different backends. This seems unecessary and confusing. Instead, I feel it would be simpler (in terms of implementation and use) to expose two different structs. Making these look the same is what the traits are for and I fear using feature flags as is done here is primarily a recipe for confusion. Open to thoughts on this, this is just my thinking getting to this a bit delayed.

@posborne posborne self-requested a review January 4, 2020 06:15
@ryankurte
Copy link
Contributor

I question the choice to expose struct Pin with the same name for different backends.

yeah this is a good point, would renaming to CdevPin and SysfsPin for the impls work for you, then the feature flag is just selecting which is re-exported as Pin (which we need for backwards compatibility)?

Probably the main thing to consider changing here would be to do the additional conditional compilation to allow for completely dropping the sysfs gpio dep if the feature is not selected.

seems reasonable to me, i guess this would look like adding a gpio_sysfs feature, then what was re-exported as Pin by default would depend on the combination of flags?

tangentially (and outside the scope of this PR), is there a point at which we want to switch people from one to the other? and, is there some way we could do this automagically at runtime instead of requiring people to compile specifically for the gpio mode? (not that support for older kernels doesn't always require a GLIBC dance anyway)

@ryankurte
Copy link
Contributor

@posborne the CI issue is fixed in #31 if you have any time to quickly review that

@posborne
Copy link
Member

posborne commented Jan 6, 2020

yeah this is a good point, would renaming to CdevPin and SysfsPin for the impls work for you, then the feature flag is just selecting which is re-exported as Pin (which we need for backwards compatibility)?

I think regardless we will not be backwards compatible, right unless someone changes the features around. Since we having a semver move to 0.3 I think it probably makes sense to introduce the breakage and avoid trying to do the rename. The names you propose look reasonable to me. Doing things this way also would allow enabling both features if desired (this could make sense for some people as people may want to use cdev for some new stuff but might still rely on udev rules to setup symlinks which would be used with sysfs).

tangentially (and outside the scope of this PR), is there a point at which we want to switch people from one to the other?

I think we just put the deprecation front and center and focus development on the newer stuff. The fact of the matter is that there are a lot of engineers who may want to use rust but will be continuing to work against systems that do not have cdev even after sysfs_gpio is deprecated in upstream kernels. Thinking specifically of 3.10 based systems.

These products should move to 4.9 LTSI but that's easier said than done depending on the SoC vendor and drivers in use. Right now I think we focus on making sure that people can use cdev and over push them that way; the hammer can come a bit later.

@almusil
Copy link
Contributor Author

almusil commented Jan 6, 2020

yeah this is a good point, would renaming to CdevPin and SysfsPin for the impls work for you, then the feature flag is just selecting which is re-exported as Pin (which we need for backwards compatibility)?

I think regardless we will not be backwards compatible, right unless someone changes the features around. Since we having a semver move to 0.3 I think it probably makes sense to introduce the breakage and avoid trying to do the rename. The names you propose look reasonable to me. Doing things this way also would allow enabling both features if desired (this could make sense for some people as people may want to use cdev for some new stuff but might still rely on udev rules to setup symlinks which would be used with sysfs).

IMO that make sense since we can break the backward comapibility. So I'll prepare commit that introduces SysfsPin and CdevPin enabled with different features. Does it work for you?

tangentially (and outside the scope of this PR), is there a point at which we want to switch people from one to the other?

I think we just put the deprecation front and center and focus development on the newer stuff. The fact of the matter is that there are a lot of engineers who may want to use rust but will be continuing to work against systems that do not have cdev even after sysfs_gpio is deprecated in upstream kernels. Thinking specifically of 3.10 based systems.

These products should move to 4.9 LTSI but that's easier said than done depending on the SoC vendor and drivers in use. Right now I think we focus on making sure that people can use cdev and over push them that way; the hammer can come a bit later.

@posborne
Copy link
Member

posborne commented Jan 6, 2020

IMO that make sense since we can break the backward comapibility. So I'll prepare commit that introduces SysfsPin and CdevPin enabled with different features. Does it work for you?

Sounds good to me.

The SysfsPin export can be enabled with feature flag "gpio_sysfs".
The CdevPin export can be enabled with feature flag "gpio_cdev".
@almusil almusil force-pushed the cdev_sysfs_module branch from 0e90b03 to 6809164 Compare January 8, 2020 15:50
@almusil almusil requested a review from ryankurte January 15, 2020 07:11
@nastevens nastevens removed their assignment Jan 21, 2020
README.md Outdated
Since Linux kernel v4.4 the use of sysfs GPIO was deprecated and replaced by the character device GPIO.
See [gpio-cdev documentation](https://github.com/rust-embedded/gpio-cdev#sysfs-gpio-vs-gpio-character-device) for details.

This crate includes feature flag `gpio_cdev` that exposes `CdevPin` as wrapper around `LineHandle` from [gpio-cdev](https://crates.io/crates/gpio-cdev).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could also have a note on dropping linehandles here and in the rustdocs for the CdevPin?

(relates to: rust-embedded/gpio-cdev#29)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if you could also add the notes to the changelog that'd be excellent, otherwise one of us can do it before releasing.

(thanks again for all your work / sorry for the back and forth!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I was happy to help, thanks. Is there anything else I could do for the project?

@ryankurte ryankurte self-assigned this Jan 21, 2020
@almusil almusil requested a review from ryankurte February 5, 2020 09:06
Copy link
Member

@posborne posborne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay in review. The updates look great to me. Thanks for your patience and contribution!

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 2, 2020

Build succeeded

@bors bors bot merged commit c921d3f into rust-embedded:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Review is incomplete T-embedded-linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants